{% extends _globals.config.layout %}

{% block style %}
    <link rel="stylesheet" href="/assets/libs/highlight/styles/{{ _globals.params.codeStyle }}.css">
{% endblock %}

{% block bottomScript %}
    <script src="/assets/libs/highlight/highlight.pack.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>
{% endblock %}

{% block body %}
  <div class="box box-solid">
    <div class="box-body">

      <h1 class="article-title">{{ detail.title }}</h1>

      <div class="article-info">
        {% if detail.tags %} {{ _globals.lang.tags }} : {% endif %}

        {% for tag in detail.tags %}
            <span class="label label-primary">{{ tag.name }}</span>
        {% endfor %}

        {{ _globals.lang.author }} : <span class="label label-success">{{ detail.user ? detail.user.username : '' }}</span>

        {% if detail.publishTime %}
            {{ _globals.lang.publishTime }} : <span class="label label-success">{{ detail.publishTime|date('Y-m-d') }}</span>
        {% endif %}


        {% if detail.readCount %}
            {{ _globals.lang.readCount }} : <span class="label label-success">{{ detail.readCount }}</span>
        {% endif %}

        {# operate btn #}
        {% if _globals.user.isLogin() %}
            <div class="pull-right">
                <a class="btn btn-info btn-xs" href="{{ path_for('content', {'action' : 'edit'}, {'id': detail.id}) }}">
                    <span class="glyphicon glyphicon-pencil"></span>
                    {{ _globals.lang.pageEdit }}
                </a>
                <a class="btn btn-danger btn-xs" href="{{ path_for('content',{'action':'del'}, {'id': detail.id}) }}">
                    <span class="glyphicon glyphicon-remove"></span>
                    {{ _globals.lang.pageDel }}
                </a>
            </div>
        {% endif %}
      </div>

      <div class="article-content">
        {{ detail.content|raw }}
      </div>

      <nav class="article-nav">
        <ul class="pager">
            {% if prevPage is defined and prevPage is iterable %}
                <li>
                    <a href="{{ prevPage.url }}">
                        <span aria-hidden="true">&larr;</span> {{ prevPage.title }}
                    </a>
                </li>
            {% elseif prevPage is defined and prevPage != false %}
                <li class="disabled"><a href="#"><span aria-hidden="true">&larr;</span> {{ _globals.lang.noPage }}</a></li>
            {% endif %}

            {% if nextPage is defined and prevPage is iterable %}
                <li>
                    <a href="{{ nextPage.url }}">
                        {{ nextPage.title }} <span aria-hidden="true">&rarr;</span>
                    </a>
                </li>
            {% elseif prevPage is defined and prevPage != false %}
                <li class="disabled"><a href="#">{{ _globals.lang.noPage }} <span aria-hidden="true">&rarr;</span></a></li>
            {% endif %}
        </ul>
      </nav>
    </div>
  </div>

{% endblock %}